import AntModal from '@/components/pt/dialog/AntModal'
import AdvanceTable from '@/components/pt/table/AdvanceTable'
import { listBizOrderProcessRecord,updateBizOrderProcessRecord } from '@/api/biz/bizOrderProcessRecord'
import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types'

export default {
  name: 'CreateForm',
  components: {
    AntModal,
    AdvanceTable
  },
  data() {
    return {
      open: false,
      closeDialog: true,
      spinning: false,
      delayTime: 100,
      labelCol: { span: 4 },
      wrapperCol: { span: 14 },
      loading: false,
      disabled: false,
      total: 0,
      id: undefined,
      formTitle: '',
      // 表单参数
      form: {},
      rules: {},
      columns: [
        {
          title: '工序编号',
          dataIndex: 'processCode',
          ellipsis: true,
          align: 'center',
          width: '12.8%'
        },
        {
          title: '工序名称',
          dataIndex: 'processName',
          align: 'center',
          width: '12.8%'
        },
        {
          title: '加工量',
          dataIndex: 'processVol',
          align: 'center',
          width: '12.8%'
        },
        {
          title: '完成量',
          dataIndex: 'completedVol',
          align: 'center',
          width: '12.8%',
          scopedSlots: {
            customRender: 'completedSlot'
          }
        },
        {
          title: '单位工资',
          dataIndex: 'unitSalary',
          align: 'center',
          width: '12.8%'
        },
        {
          title: '操作',
          dataIndex: 'operation',
          align: 'center',
          width: '10%',
          scopedSlots: { customRender: 'operation' }
        }
      ],
      list: [],
      selectedRowKeys: [],
      ids: [],
      recordList: []
    }
  },
  filters: {},
  created() {},
  computed: {},
  watch: {},
  mounted() { },
  methods: {
    onClose() {
      this.open = false
      this.reset()
      this.$emit('close')
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
      this.$emit('close')
    },
    // 表单重置
    reset() {
      this.form = {}
    },
    getList(orderId) {
      listBizOrderProcessRecord({orderId:orderId}).then(response => {
        this.recordList = response.data.list
        this.total = response.data.total
        this.$forceUpdate();
      })
    },
    handleRecord(row) {
      this.reset()
      this.open = true
      this.formTitle = '工序进度';
      this.form = row
      this.$nextTick(() => {
        this.getList(this.form.id);
      })
    },
    handleUpdate(row) {
      console.log(row,'row')
      updateBizOrderProcessRecord(row).then(response => {
        this.$message.success('更新成功', 3)
        this.getList(this.form.productId);
      })
    },
  }
}
